<template>
  <nav class="navbar">
    <router-link to="/" class="logo">
      <img src="/valorant-logo.png" alt="Valorant Logo" />
              <span class="logo-text">瓦洛兰特军火展示网</span>
    </router-link>
    <div class="nav-links">
      <router-link to="/" class="nav-link">主页</router-link>
      <template v-if="isAuthenticated">
        <router-link to="/arsenal" class="nav-link">军火一览</router-link>
        <router-link to="/wishlist" class="nav-link">
          愿望清单
          <span v-if="wishlistCount" class="wishlist-count">{{ wishlistCount }}</span>
        </router-link>
        <router-link to="/search" class="nav-link">搜索</router-link>
      </template>
    </div>
  </nav>
</template>

<script>
import { computed } from 'vue'
import { useStore } from 'vuex'

export default {
  name: 'NavBar',
  setup() {
    const store = useStore()

    const isAuthenticated = computed(() => store.state.auth.isAuthenticated)
    const wishlistCount = computed(() => store.state.wishlist.length)

    return {
      isAuthenticated,
      wishlistCount
    }
  }
}
</script>

<style scoped>
.navbar {
  background-color: #ff4655;
  padding: 1rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 1000;
}

.logo {
  display: flex;
  align-items: center;
  text-decoration: none;
}

.logo img {
  height: 40px;
  transition: transform 0.3s;
}

.logo-text {
  color: white;
  font-size: 1.2rem;
  font-weight: bold;
  margin-left: 1rem;
  letter-spacing: 1px;
  text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.2);
}

.logo img:hover {
  transform: scale(1.1);
}

.logo:hover .logo-text {
  color: #1f1f1f;
  transition: color 0.3s;
}

.nav-links {
  display: flex;
  gap: 2rem;
}

.nav-link {
  color: white;
  text-decoration: none;
  font-size: 1.1rem;
  font-weight: 600;
  transition: color 0.3s;
  padding: 0.5rem 1rem;
  border-radius: 4px;
  position: relative;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.nav-link:hover {
  color: #1f1f1f;
  background-color: rgba(255, 255, 255, 0.2);
}

.router-link-active {
  background-color: rgba(255, 255, 255, 0.2);
}

.wishlist-count {
  background-color: white;
  color: #ff4655;
  font-size: 0.8rem;
  padding: 0.2rem 0.5rem;
  border-radius: 999px;
  min-width: 1.5rem;
  text-align: center;
}
</style> 